/**  
 * @Title:  WebAppConfigurer.java   
 * @Package com.platform.config    
 * @author: <a href="mailto:15909910367@163.com">吴先生</a> 
 * @date:   2022年10月28日 下午9:20:11   
 * @version V1.0 
 * @Copyright: 2022 吴先生.
 */
package com.platform.config;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.platform.aspect.ApiLogAspect;
import com.platform.resolver.BeanArgumentResolver;

/**
 * @ClassName: WebAppConfigurer
 * @Description: 解决前后端分离的跨域问题
 * @date: 2022年10月28日 下午9:20:11
 * @author: <a href="mailto:15909910367@163.com">吴先生</a>
 * @Copyright: 2022 吴元森.
 */
@Configuration
public class WebAppConfigurer implements WebMvcConfigurer {

	@Autowired
	private BeanArgumentResolver beanArgumentResolver;

	@Override
	public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
		WebMvcConfigurer.super.addArgumentResolvers(resolvers);
		resolvers.add(beanArgumentResolver);
	}

	@Override
	public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
		configurer.enable();
	}

	@Override
	public void addResourceHandlers(ResourceHandlerRegistry registry) {
		// 处理静态资源的，例如：图片，js，css等
		registry.addResourceHandler("/resource/**").addResourceLocations("file:" + LocalAttachPath.get("file.root"));
	}

	@Bean
	public ApiLogAspect apiLogAspect() {
		return new ApiLogAspect();
	}
}
